perm filename MAP.PAL[HAL,HE]6 blob sn#192272 filedate 1975-12-16 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00005 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	 Routines for use of the glorious Panofsky map with the
C00004 00003	  BNCTAB, Macros
C00005 00004	  Map definitions
C00007 00005	  MAPINIT, SWITCH
C00010 ENDMK
C⊗;
COMMENT ⊗ Routines for use of the glorious Panofsky map with the
interpreter and AL runtime.  This version requires that K2 be the
kernel.  We take care of switching maps ourselves, but the kernel
sets up the mapping into four counties as follows:
	0	 27777	straight-through
    30000	117777	mapped
   120000	157777	straight-through
   160000	177777	into I/O space
The mapped region, 30000:117777 is placed in physical locations
30000, 160000, 250000, and 340000 for counties 0, 1, 2, and 3,
respectively.

Calling a routine in a foreign county is done this way:

	BOUNCE #LNAME		;Link name

The link name is an pointer into the link table.  Each entry in that
table is two words.  The first is the routine's address in that
county, and the second is the county number.  The switch routine will
keep track of the stack and will set the return address to something
in itself.  It handles the return and does all the necessary fixup. ⊗
;  BNCTAB, Macros

LTAB:	.BLKW 40	;Enough for 20 links
BNCTAB:	
	II == BNCTAB	;
	XX LALAID	;address
	XX FOO		;county
	. = II

.MACRO BOUNCE WALL
	MOV WALL,-(SP)		;The link name of the routine
	JSR PC,SWITCH		;A routine in common space to do it all
.ENDM

.MACRO EXTERNAL LAB,LLAB	
	LAB:
	PUTLOC BNCTAB+LLAB,LAB	;The routine's address in that county
	PUTLOC BNCTAB+LLAB+2,COUNTY	;The county.
.ENDM

.MACRO PLACE PHYS,VIRT
    .OFFSET 0
    .=PHYS
    .OFFSET VIRT-PHYS
.ENDM
;  Map definitions

;Page tables:  100 words each, one per page
MAPTB0=166000
MAPTB1=166200
MAPTB2=166400
MAPTB3=166600

        ;Page table entries (each one for 2000 bytes)
	MAPWRT==100000	;Page written
	MAPACC==040000	;Page accessed
	MAPWOK==020000	;Write permission
	MAPROK==010000	;Read permission
	MAPUBS==004000	;1 => Unibus address
;	        003777	Physical page number

;Map space table
MAPKI=167020
MAPKD=167030
MAPSI=167022
MAPSD=167032
MAPUI=167026
MAPUD=167036

        ;Map space table entries
        ;       001400          Page table number
        ;       000200          Transparent mode ( 1 => no mapping)
        ;       000176          Max virtual page (*2)

MAPSR0=167000

	;Status register 0 entries
	MAPENB==100000	;Enable mapping
	MAPMPV==040000	;Max page violation
	MAPRPV==020000	;Read violation
	MAPWPV==010000	;Write violation
;	      	    30	;PC mode of the violating instruction
;		    04	;Error was in I space
;		    03	;Mode of the violating reference

MAPSR1=167002		;Virtual address of the bad reference

MAPSR2=167004		;Virtual PC of 1st word of offending instruction

;  MAPINIT, SWITCH

MAPINIT:
	EVMAK		;Make a new mapping interlock event
	MOV (SP),MAPEVT	;
	EVSIG 		;Give it one signal
	MOV #SWSTCK,PTR	;Initialize the special stack
	RTS PC		;

SWITCH:
COMMENT ⊗ The stack holds a pointer into the LTAB. Map exclusion is
kept throughout this routine to keep other processes from confusing
the speci{␈'∂Zq↓αSFKMβWv3?KS.sπS↔gIβCK/3↔;S~β7?K*βS#πrβ?;∃π≠←'S≡@4+∪.+A9↓∧;'[∃π≠?7∃π##?W>CQβSzβK↔O}c[';:βS#'~βCK?⊗c↔51εc'/∃ε;'['v9β∧4WβK?∂/≠MβSF)β∂πε3'fKSeβ&yβ∪=ε;eβw+7↔∩β?→β∨;'S∂F+M1β&C∃β∂∂βπ'fKSd4V∪↔';:βK↔O'∪'∂S.!84(0h(&⊗5:ε&Q∧jεB⊗5 %n↔w#↔Iβ∨∪'S'≡1βK.;'?8hP&6>2αIA1jBNA$KZOπ[*αI@4PJ6>Y¬⊃E15E~A$%]≠π[∃¬⊃D4(Lj>Yα¬"I2IλInS#*βOSπ≡Yβ≠?∩βS#'~βK?W&K;∀4PJ6>Yβ!"NAJa5"I
H%nO∂3∃βSF)βK↔'+K9β∞#∪K↔∨_4(&lzYα6
αV%1jBIE$KZ←#↔⊗)β←∃εK∃β≡{7';:β≠K?hh(&6⎇1↓Y"≥↓%15E⊃E%n≡[∃β&C∃βC}K;S↔∩β';SzβS#∃∧bRελhP&6>2↓"IEJbI@%]⊃Aα⎇πβ?';&+Iβ'w#=α2$
λ4(Lj>Y↓∩BIA%e⊃@%n∪↓α⎇β&+O'K.!β∂?.sSd4PJεN!α→EA2∪%l4PJε∩⊃α→E]Ye⊃@%nnc'7.iβπ∂≡+OO'⊗c∃βC∞;∀4(Lj>Yα∪↓26ε¬*$%n≡+QβSF)β';∨#KW∂&K?9β∨βπ∂∀hP&6>2αIA2l
BV⊂KZO↔Qπ##∃β&S¬β∨βπ∂∀hP&6>2↓"IEJY2I@KZIAαzβC?'w#↔IβNsS=αe"ελ4PJ6>Y¬⊃E2B%⊂%l4PJ6>YαBIA%e"⊗6AInS#*βπ∪∪⊗+OMβ&yβ+Wo↓βS<hP&6>2↓"NAJY2IDKZK↔O&{K∃α∪λ4(&lzY↓"≥↓%-2∪%nK/≠S?K*αI@4PJRNQαBNA%XIn∨↔"βK'⊃ε{→β?f!βK↔'+K9β∞#∪K↔∨_4(&%~Q↓"≥↓%,%\;↔Qβ⊗K⊃β?2βS#∃πβ?';&+IβSzα2Rε⊂h(4(LRNIα∧→2αR,j@%nW+7Aβ&yβS#*βK?W&K;∃1π∪↔SW⊗qβ#↔⊗(4(4PJ6>Y∧αBRIdjεBVHIn∨=ε∪π∂-π#=β?f!βOC∞≠∀4(Lj>Yα¬αRI2l
BV⊂KZ∨=β⊗∂-β&yβ?3"βOCπ≡(4(&"⊃↓
∩bBRHKX4(&lzYαα¬"I15E~A$%]##∃β⊗+SWKrβπ∪∪⊗+OL4PJε∩⊃α→I2B%⊂%l4PJ⊗ZNL9α6ε∧*ZP%\+;⊃β}1β∂KO#'∂πbβK↔∨N{84(M∩RMα∧_$%n⊗+SWKph(4*$*6AhJr
2.:↓D$%]3πK'∞∪3∃βNqαN↑M"∞ 4UαRIhJr
2.:↓D$%]3πK'∞∪3∃βNqαN↑M"∞ 4PI:
2]9↓EAInOS∞≠-βW≡+⊃β'rαN↑&$~ 4*≥:NR∞[Q↓:
dZ]↓DHInS?αβ?→β∨#π∂,hP↓g+∂